<template>
  <div class="app-container content_app">
    <p
      style="
        text-align: center;
        font-size: 24px;
        font-weight: 700;
        margin: 10px 0;
      "
    >
      資產負債表
    </p>
    <div>
      <p style="margin: 10px 0">
        <span> 公司名稱： </span>
        <span>永力投資有限公司</span>
      </p>
      <p style="margin: 10px 0">
        <span> 會計期間： </span>
        <span>
          <el-date-picker
            v-model="dateArr"
            value-format="yyyy-MM-dd"
            type="daterange"
            range-separator="至"
            start-placeholder="開始日期"
            end-placeholder="結束日期"
          >
          </el-date-picker>
          <el-button
            style="margin-left: 16px"
            type="primary"
            size="mini"
            @click="getList"
            >生成</el-button
          >
          <el-button
            style="margin-left: 16px"
            type="primary"
            size="mini"
            @click="exportExcel"
            >導出</el-button
          >
        </span>
      </p>
      <p style="margin: 10px 0">
        <span> 單位： </span>
        <span> 港幣 </span>
      </p>
    </div>
    <el-table
      class="table_content"
      :data="tableData"
      border
      stripe
      style="width: 100%"
      :row-style="{ height: '26px' }"
    >
      <el-table-column prop="data1" label="資產"> </el-table-column>
      <el-table-column prop="data2" label="行次" width="100"> </el-table-column>
      <el-table-column prop="data3" label="期初數"> </el-table-column>
      <el-table-column prop="data4" label="期末數"> </el-table-column>
      <el-table-column prop="data5" label="負債及所有者權益(或股東權益)">
      </el-table-column>
      <el-table-column prop="data6" label="行次" width="100"> </el-table-column>
      <el-table-column prop="data7" label="期初數"> </el-table-column>
      <el-table-column prop="data8" label="期末數"> </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getAccountAssetsLiabilities } from "@/api/biz/entry";

export default {
  name: "AssetsLiabilities",
  components: {},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 查询參數
      queryParams: {
        startDate: "2023-12-12",
        endDate: "2024-06-12",
      },
      dateArr: [
        // this.$moment().subtract(1, "years").format("YYYY-MM-DD"),
      this.$moment().startOf('month').format("YYYY-MM-DD"),
        this.$moment().format("YYYY-MM-DD"),
      ],
      tableData: [
        {
          data1: "流動資產：",
          data2: "",
          data3: "",
          data4: "",
          data5: "流動負債:",
          data6: "",
          data7: "",
          data8: "",
        },
        {
          data1: "貨幣資金",
          data2: "1",
          data3: "",
          data4: "",
          data5: "短期借款",
          data6: "18",
          data7: "",
          data8: "",
        },
        {
          data1: "短期投資",
          data2: "2",
          data3: "",
          data4: "",
          data5: "應付职工薪酬",
          data6: "19",
          data7: "",
          data8: "",
        },
        {
          data1: "應收票據",
          data2: "3",
          data3: "",
          data4: "",
          data5: "應付費用",
          data6: "20",
          data7: "",
          data8: "",
        },
        {
          data1: "應收股利",
          data2: "4",
          data3: "",
          data4: "",
          data5: "預收賬款",
          data6: "21",
          data7: "",
          data8: "",
        },
        {
          data1: "應收利息",
          data2: "5",
          data3: "",
          data4: "",
          data5: "其他應付款",
          data6: "22",
          data7: "",
          data8: "",
        },
        {
          data1: "應收賬款",
          data2: "6",
          data3: "",
          data4: "",
          data5: "應付董事",
          data6: "23",
          data7: "",
          data8: "",
        },
        {
          data1: "應收董事",
          data2: "7",
          data3: "",
          data4: "",
          data5: "應交稅費",
          data6: "24",
          data7: "",
          data8: "",
        },
        {
          data1: "預付賬款",
          data2: "8",
          data3: "",
          data4: "",
          data5: "流動負債合計",
          data6: "25",
          data7: "",
          data8: "",
        },
        {
          data1: "存貨",
          data2: "9",
          data3: "",
          data4: "",
          data5: "長期負債",
          data6: "",
          data7: "",
          data8: "",
        },
        {
          data1: "待攤費用",
          data2: "10",
          data3: "",
          data4: "",
          data5: "長期借款",
          data6: "26",
          data7: "",
          data8: "",
        },
        {
          data1: "其他應收款",
          data2: "11",
          data3: "",
          data4: "",
          data5: "負債合計",
          data6: "27",
          data7: "0.00",
          data8: "0.00",
        },
        {
          data1: "流動資產合計",
          data2: "12",
          data3: "0.00",
          data4: "0.00",
          data5: "所有者權益:",
          data6: "",
          data7: "",
          data8: "",
        },
        {
          data1: "非流動資產：",
          data2: "",
          data3: "",
          data4: "",
          data5: "實收資本",
          data6: "28",
          data7: "",
          data8: "",
        },
        {
          data1: "長期投資",
          data2: "13",
          data3: "",
          data4: "",
          data5: "實收資本淨額",
          data6: "29",
          data7: "",
          data8: "",
        },
        {
          data1: "固定資產淨值",
          data2: "14",
          data3: "",
          data4: "",
          data5: "資本公積",
          data6: "30",
          data7: "",
          data8: "",
        },
        {
          data1: "無形資產淨值",
          data2: "15",
          data3: "",
          data4: "",
          data5: "未分配利潤",
          data6: "31",
          data7: "",
          data8: "",
        },
        {
          data1: "非流動資產合計",
          data2: "16",
          data3: "0.00",
          data4: "0.00",
          data5: "所有者權益（或股東權益）合計",
          data6: "32",
          data7: "0.00",
          data8: "0.00",
        },
        {
          data1: "資產總計",
          data2: "17",
          data3: "0.00",
          data4: "0.00",
          data5: "負債及所有者權益（或股東權益）總計",
          data6: "33",
          data7: "0.00",
          data8: "0.00",
        },
      ],
    };
  },
  created() {},
  mounted() {
    console.log( this.$moment().startOf('month').format("YYYY-MM-DD"));
    this.getList();
  },
  methods: {
    getList() {
      this.queryParams.startDate = this.dateArr[0];
      this.queryParams.endDate = this.dateArr[1];
      getAccountAssetsLiabilities(this.queryParams).then((response) => {
        console.log(response);
        let dataSet = response.data;
        this.tableData[1].data3 = dataSet.qcIncomeAmount;
        this.tableData[1].data4 = dataSet.qmIncomeAmount;
        this.tableData[6].data3 = dataSet.qcReceivableAmount;
        this.tableData[6].data4 = dataSet.qmReceivableAmount;
        this.tableData[7].data3 = dataSet.qcReceivableOfDirectors;
        this.tableData[7].data4 = dataSet.qmReceivableOfDirectors;
        this.tableData[8].data3 = dataSet.qcPrepayments;
        this.tableData[8].data4 = dataSet.qmPrepayments;
        this.tableData[11].data3 = dataSet.qcOtherReceivables;
        this.tableData[11].data4 = dataSet.qmOtherReceivables;
        this.tableData[12].data3 = dataSet.qcTotalCurrentAssets;
        this.tableData[12].data4 = dataSet.qmTotalCurrentAssets;
        this.tableData[18].data3 = dataSet.qcTotalAssets;
        this.tableData[18].data4 = dataSet.qmTotalAssets;

        this.tableData[1].data7 = dataSet.qcShortTermBorrowing;
        this.tableData[1].data8 = dataSet.qmShortTermBorrowing;
        this.tableData[2].data7 = dataSet.qcPayableEmployee;
        this.tableData[2].data8 = dataSet.qmPayableEmployee;
        this.tableData[3].data7 = dataSet.qcExpenseAmount;
        this.tableData[3].data8 = dataSet.qmExpenseAmount;
        this.tableData[4].data7 = dataSet.qcAdvanceReceipts;
        this.tableData[4].data8 = dataSet.qmAdvanceReceipts;
        this.tableData[5].data7 = dataSet.qcOtherPayables;
        this.tableData[5].data8 = dataSet.qmOtherPayables;
        this.tableData[6].data7 = dataSet.qcPayableOfDirectors;
        this.tableData[6].data8 = dataSet.qmPayableOfDirectors;
        this.tableData[7].data7 = dataSet.qcPayableTaxes;
        this.tableData[7].data8 = dataSet.qmPayableTaxes;
        this.tableData[8].data7 = dataSet.qcTotalCurrentLiabilities;
        this.tableData[8].data8 = dataSet.qmTotalCurrentLiabilities;
        this.tableData[10].data7 = dataSet.qcLongLoans;
        this.tableData[10].data8 = dataSet.qmLongLoans;
        this.tableData[11].data7 = dataSet.qcTotalDebt;
        this.tableData[11].data8 = dataSet.qmTotalDebt;
        this.tableData[13].data7 = dataSet.qcPaidCapital;
        this.tableData[13].data8 = dataSet.qmPaidCapital;
        this.tableData[14].data7 = dataSet.qcNetPaidCapital;
        this.tableData[14].data8 = dataSet.qmNetPaidCapital;
        this.tableData[15].data7 = dataSet.qcCapitalReserve;
        this.tableData[15].data8 = dataSet.qmCapitalReserve;
        this.tableData[16].data7 = dataSet.qcUndistributedProfits;
        this.tableData[16].data8 = dataSet.qmUndistributedProfits;
        this.tableData[17].data7 = dataSet.qcTotalOwnerSEquity;
        this.tableData[17].data8 = dataSet.qmTotalOwnerSEquity;
        this.tableData[18].data7 = dataSet.qcLiabilitiesAndOwnerSEquity;
        this.tableData[18].data8 = dataSet.qmLiabilitiesAndOwnerSEquity;
      });
    },
    exportExcel() {
      this.download_get(
        "biz/entry/accounting/assetsLiabilities/export",
        {
          ...this.queryParams,
        },
        `資產負債表_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
<style scoped lang="scss">
::v-deep .table_content {
  th {
    padding: 0 !important;
    height: 10px;
    line-height: 10px;
  }
  td {
    padding: 0 !important;
    height: 30px;
    line-height: 30px;
  }
}
</style>
